Repository navigation
feat(extraction): index Solidity (.sol) at the extraction tier - #151
Merged
Merged
Conversation
Ports upstream colby Solidity support (#1170). `.sol` files now index their contracts, libraries, interfaces, structs, enums, functions, modifiers, constructors/fallback/receive, state variables, events, errors, imports, call edges, and `is` inheritance as a first-class Tier-1 language, via the tree-sitter-solidity crates.io grammar (no vendored grammar). Adds the Language::Solidity variant, the `.sol` extension mapping, a SOLIDITY_SPEC mapping the grammar's contract/library/interface containers to class-like symbols with synthetic names for the AST-nameless constructor, fallback, and receive callables, the store language parser arm so an indexed `.sol` file round-trips through the DB, and a dedicated solidity golden fixture. Six Solidity-guarded walker extensions cover the AST shapes tree-sitter-solidity spells differently from the C-family grammars: `is`-inheritance specifiers, the direct-`name` fields on state variables and struct members, leaf `enum_value` members, header-position modifier invocations (emitted as calls, not decorations), top-level constants, and file-level free events and errors — each gated to Solidity so no other language's extraction changes. Contract-to- interface inheritance rides the existing resolver, which promotes the extracted Extends to Implements. There is no framework-resolution bridge to defer: the upstream extractor is entirely extraction, and its implements reclassification and import resolution ride machinery this port already has. The language enum is a stored TEXT value, not DDL, so the golden .schema is unchanged and the seven existing golden fixtures are byte-identical (no regen); only the new solidity fixture is added.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #151 +/- ##
========================================
Coverage 95.49% 95.50%
========================================
Files 119 120 +1
Lines 58414 58834 +420
========================================
+ Hits 55783 56189 +406
- Misses 2631 2645 +14
🚀 New features to boost your workflow:
|
sunerpy
added a commit
that referenced
this pull request
Nov 19, 2026
…rates
Rust projects had no routes in the index and no framework edges. A
resolver named `rust` now ports upstream's Rust resolver from `rust.ts`
and its Cargo workspace crate map from `cargo-workspace.ts` as they
stand at e8ddc4e2.
Rust is detected by a root Cargo.toml, read whether or not it is
indexed. A manifest below the root, a workspace member's or a
fixture's, detects nothing.
Routes come from three forms, read on comment-stripped text: attribute
routes (actix's and rocket's #[get("/users")]), each referencing the
next fn; axum's .route("/users", get(a).post(b)), one route for each
method router at the call's top level, none for a get( inside a closure
handler; and actix's builder API, web::resource("/p") chains with
web::METHOD().to(h) and an ANY route for a leading .to(h), and App-level
.route("/p", web::get().to(h)). An axum or builder route stays on its
.route line, and its reference to the handler sits where the handler's
last segment is written (#2359), so the scope rule reads the handler's
own line.
References resolve by upstream's conventions through the shared name
heuristic (#2225): a ..._handler or handle_... function, a ...Service or
...Repository struct or trait, and a CamelCase model struct, each
preferring its conventional folders; and a lowercase name as a module,
the root's src/<name>.rs or src/<name>/mod.rs, else a workspace crate's
src/lib.rs or src/main.rs. The heuristics take only a name the Rust
scope rule lets the reference see (#2224, and #2214's framework half):
no item inside a function body, and no project item where the name is
an outside crate's import or a path through one.
The crate map (#151) reads the root manifest's [workspace] members,
expands glob members through a directory listing the resolution
contexts now offer, and maps each member's [package] name and its `_`
alias to the member's directory.
The module rule links a file node, which no reference's name reaches,
so a sync that adds or removes a root module or a crate root retries
the references named for it: unresolved ones by name, resolved ones at
their sites. So does a sync that keeps one whose file node comes or
goes: a file over max_file_size stays tracked without any node. A new
marker, rust_crate_roots_version, makes a sync that finds it missing
re-resolve every Rust file. The workspace's manifests are the Rust
control kind's inputs.
Kept Rust behavior, recorded in KNOWN_DIFFS:
- a convention whose pick declines ends the chain, the module rule's
too, where upstream tries the next rule only when no candidate exists;
- a module is its file node, where upstream takes the file's first node;
- a workspace's members stay inside the project: an absolute member
(`/` included) or one leaving the root, and a glob whose static
prefix is one, are neither read nor listed; a glob's walk is sorted,
a name two members give names neither, and a glob reads the
picomatch forms a Cargo workspace writes;
- a builder route's handler column is a byte column, as the Rust scope
rule reads it.
The goldens are unchanged, every corpus identical under
scripts/regen-goldens.sh --check: no golden fixture has a root
Cargo.toml (the servers corpus keeps its axum/ and actix/ manifests one
level down), so none detects Rust.
Precision: 78 of 84 corpora index identically. This repository's
snapshot, tokio, realworld-axum-sqlx, axum, actix/examples and
crates.io differ; git detects Rust and is unchanged. The four corpora
#2359 validated link as many routes to handlers as it reported at the
same commits: 19, 204, 116 and 5. 2288 `use` declarations of workspace
crates now import the crate's root file, 4 of them for a registry
crate named like a member, and 3755 references keep their targets at
the conventions' confidence. Of 453 references that move, 389 reach
the declaration the name means, among them 279 `&Store` parameters
here that leave the core crate's trait for the store's struct, and 9
are wrong before and after. 55 move away from the right target, as
upstream's rules move them: a model struct wins a tie with name
matching (17) or outranks it (2), and the model rule answers
`implements`, so crates.io's 36 `impl BackgroundJob for` leave the
worker trait for a struct of that name and the 36 trait-dispatch calls
synthesized from them go. The module rule also newly links 12
lowercase names in crates.io to root module files they do not mean:
builder calls such as `.config(`, the registry `sentry` crate and a
member's own `cloudfront` module.
On a CI runner, init, sync and peak memory stay within the performance
lines on the seven measured workloads across five corpora. Re-syncing
an edited actix-examples main.rs takes 1.12 times as long as before,
an edited axum routing test 1.10 times, and an edited Cargo.toml 1.03
(tokio-stream) and 1.06 (axum-extra) times.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upstream-sync DEFER item H2 — adds Solidity (.sol) as a first-class Tier-1 extraction language (colby #1170), via the
tree-sitter-solidity = "1.2.13"crates.io grammar (no vendored grammar)..solfiles now index contracts/libraries/interfaces, structs, enums, functions, modifiers, constructors/fallback/receive, state variables, events, errors, imports, call edges, andisinheritance.Language::Solidityvariant +.solmapping;SOLIDITY_SPECmaps the contract/library/interface containers to class-like symbols with synthetic names for the AST-nameless constructor/fallback/receive; storeparse_languagelearns"solidity"; dedicatedsoliditygolden fixture.is-inheritance specifiers, direct-namefields on state variables/struct members, leafenum_valuemembers, header-position modifier invocations (emitted as Calls, not Decorates), top-level constants, and file-level free events/errors — each gated to Solidity so no other language's extraction changes.Verification
make cigreen (fmt + clippy + test + guardrail);cargo test --workspace0 failed.sol_maps_to_solidity,solidity_contract_is_records_extends,solidity_constructor_fallback_receive_synthetic_names-equivalents,solidity_modifier_guard_is_call,solidity_file_level_event_error_are_fields+..._do_not_double_emit_inside_contract, enum round-trip at 38,soliditygolden self-equivalence + committed-match,schema_paritygreen..schemaunchanged (language is a stored TEXT value, not DDL). Post-resolution golden shows resolvedImplements Token→IERC20+ resolved Calls, no unresolved refs for resolved targets.Cargo.lockgains onlytree-sitter-solidity.DEFER item H2 of the 1.2.0→1.4.1 upstream sync. Remaining: Nix, HCL/Terraform, Erlang, CFML (gated); COBOL + VB.NET deferred (no crates.io grammar).